package com.songshuai.webapi.baseapi.enumerations.crm;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@AllArgsConstructor
@NoArgsConstructor
public enum CustomType {

    ONE(6006001, "潜在学员"),
    TWO(6006002, "在读学员"),
    THREE(6006003, "历史学员");

    @Getter
    private int code;
    @Getter
    private String msg;

    @SneakyThrows(IllegalArgumentException.class)
    public static int getCode(String define) {
        return CustomType.valueOf(define).code;
    }

    @SneakyThrows(IllegalArgumentException.class)
    public static String getMsg(String define) {
        return CustomType.valueOf(define).msg;
    }

    public static String getMsg(Integer code) {
        if(null!=code&&code>0){
            for(CustomType err : CustomType.values()){
                if(err.code==code){
                    return err.msg;
                }
            }
        }
        return "";
    }
}
